import pymysql

class DBTools():


    @classmethod
    def create_conn(cls):
        conn = pymysql.connect(host="192.168.242.135", port=3306, user="root", password="iTest_2022_mysql",
                           database="ihrm", charset="utf8")
        return conn
    @classmethod
    def query_one(cls, sql):
        conn = None
        cursor = None
        res = None

        conn = DBTools.create_conn()
        cursor = conn.cursor()

        cursor.execute(sql)
        res = cursor.fetchone()

        cursor.close()
        conn.close()

        return res


    def db_uid(self, sql):
        conn = DBTools.create_conn()
        cursor = conn.cursor()

        cursor.execute(sql)
        conn.commit()

        cursor.close()
        conn.close()
if __name__ == '__main__':
    res = DBTools.query_one("select *from bs_user where mobile = 13133445590;")
    print(res)